#coding=utf-8
#修改用户
file=open('d:\\test2.txt','r')
fnew=open('d:\\test3.txt','w')
select=input("请选择需要更改的方式(name/age/number)：")
while select=='name':
    name1=input("请输入需要修改的姓名：")
    name2=input("请输入需要修改的姓名为：")
    for i in file:
        b=i.split()
        if name1==b[0]:
            i=i.replace(name1,name2)
            print(b)
        fnew.write(i)
    break
while select=='age':
    age1=input("请输入需要修改的年龄：")
    age2=input("请输入需要修改的年龄为：")
    for i in file:
        b=i.split()
        if age1==b[1]:
            i=i.replace(age1,age2)
        fnew.write(i)
    break
while select=='number':
    number1=input("请输入需要修改的号码：")
    number2=input("请输入需要修改的号码为：")
    for i in file:
        b=i.split()
        if number1==b[-1]:
            i=i.replace(number1,number2)
        fnew.write(i)
    break
file.close()
fnew.close()
